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 "jingle/notifier/communicator/connection_settings.h"
7 #include "jingle/notifier/base/server_information.h"
8 #include "testing/gtest/include/gtest/gtest.h"
14 class ConnectionSettingsTest
: public ::testing::Test
{
16 ConnectionSettingsTest() {
19 net::HostPortPair("supports_ssltcp.com", 100),
23 net::HostPortPair("does_not_support_ssltcp.com", 200),
24 DOES_NOT_SUPPORT_SSLTCP
));
30 // An empty server list should always map to an empty connection
32 TEST_F(ConnectionSettingsTest
, Empty
) {
33 EXPECT_TRUE(MakeConnectionSettingsList(ServerList(), false).empty());
34 EXPECT_TRUE(MakeConnectionSettingsList(ServerList(), true).empty());
37 // Make sure that servers that support SSLTCP get mapped to two
38 // settings entries (with the SSLTCP one coming last) whereas those
39 // that don't map to only one.
40 TEST_F(ConnectionSettingsTest
, Basic
) {
41 const ConnectionSettingsList settings_list
=
42 MakeConnectionSettingsList(servers_
, false /* try_ssltcp_first */);
44 ConnectionSettingsList expected_settings_list
;
45 expected_settings_list
.push_back(
47 rtc::SocketAddress("supports_ssltcp.com", 100),
50 expected_settings_list
.push_back(
52 rtc::SocketAddress("supports_ssltcp.com", 443),
55 expected_settings_list
.push_back(
57 rtc::SocketAddress("does_not_support_ssltcp.com", 200),
59 DOES_NOT_SUPPORT_SSLTCP
));
61 ASSERT_EQ(expected_settings_list
.size(), settings_list
.size());
62 for (size_t i
= 0; i
< settings_list
.size(); ++i
) {
63 EXPECT_TRUE(settings_list
[i
].Equals(expected_settings_list
[i
]));
67 // Make sure that servers that support SSLTCP get mapped to two
68 // settings entries (with the SSLTCP one coming first) when
69 // try_ssltcp_first is set.
70 TEST_F(ConnectionSettingsTest
, TrySslTcpFirst
) {
71 const ConnectionSettingsList settings_list
=
72 MakeConnectionSettingsList(servers_
, true /* try_ssltcp_first */);
74 ConnectionSettingsList expected_settings_list
;
75 expected_settings_list
.push_back(
77 rtc::SocketAddress("supports_ssltcp.com", 443),
80 expected_settings_list
.push_back(
82 rtc::SocketAddress("supports_ssltcp.com", 100),
85 expected_settings_list
.push_back(
87 rtc::SocketAddress("does_not_support_ssltcp.com", 200),
89 DOES_NOT_SUPPORT_SSLTCP
));
91 ASSERT_EQ(expected_settings_list
.size(), settings_list
.size());
92 for (size_t i
= 0; i
< settings_list
.size(); ++i
) {
93 EXPECT_TRUE(settings_list
[i
].Equals(expected_settings_list
[i
]));
99 } // namespace notifier