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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "jingle/notifier/communicator/connection_settings.h"
#include "jingle/notifier/base/server_information.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace notifier {
namespace {
class ConnectionSettingsTest : public ::testing::Test {
protected:
ConnectionSettingsTest() {
servers_.push_back(
ServerInformation(
net::HostPortPair("supports_ssltcp.com", 100),
SUPPORTS_SSLTCP));
servers_.push_back(
ServerInformation(
net::HostPortPair("does_not_support_ssltcp.com", 200),
DOES_NOT_SUPPORT_SSLTCP));
}
ServerList servers_;
};
// An empty server list should always map to an empty connection
// settings list.
TEST_F(ConnectionSettingsTest, Empty) {
EXPECT_TRUE(MakeConnectionSettingsList(ServerList(), false).empty());
EXPECT_TRUE(MakeConnectionSettingsList(ServerList(), true).empty());
}
// Make sure that servers that support SSLTCP get mapped to two
// settings entries (with the SSLTCP one coming last) whereas those
// that don't map to only one.
TEST_F(ConnectionSettingsTest, Basic) {
const ConnectionSettingsList settings_list =
MakeConnectionSettingsList(servers_, false /* try_ssltcp_first */);
ConnectionSettingsList expected_settings_list;
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("supports_ssltcp.com", 100),
DO_NOT_USE_SSLTCP,
SUPPORTS_SSLTCP));
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("supports_ssltcp.com", 443),
USE_SSLTCP,
SUPPORTS_SSLTCP));
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("does_not_support_ssltcp.com", 200),
DO_NOT_USE_SSLTCP,
DOES_NOT_SUPPORT_SSLTCP));
ASSERT_EQ(expected_settings_list.size(), settings_list.size());
for (size_t i = 0; i < settings_list.size(); ++i) {
EXPECT_TRUE(settings_list[i].Equals(expected_settings_list[i]));
}
}
// Make sure that servers that support SSLTCP get mapped to two
// settings entries (with the SSLTCP one coming first) when
// try_ssltcp_first is set.
TEST_F(ConnectionSettingsTest, TrySslTcpFirst) {
const ConnectionSettingsList settings_list =
MakeConnectionSettingsList(servers_, true /* try_ssltcp_first */);
ConnectionSettingsList expected_settings_list;
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("supports_ssltcp.com", 443),
USE_SSLTCP,
SUPPORTS_SSLTCP));
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("supports_ssltcp.com", 100),
DO_NOT_USE_SSLTCP,
SUPPORTS_SSLTCP));
expected_settings_list.push_back(
ConnectionSettings(
talk_base::SocketAddress("does_not_support_ssltcp.com", 200),
DO_NOT_USE_SSLTCP,
DOES_NOT_SUPPORT_SSLTCP));
ASSERT_EQ(expected_settings_list.size(), settings_list.size());
for (size_t i = 0; i < settings_list.size(); ++i) {
EXPECT_TRUE(settings_list[i].Equals(expected_settings_list[i]));
}
}
} // namespace
} // namespace notifier
|