Roll WebRTC 7546:7549.
[chromium-blink-merge.git] / jingle / notifier / communicator / login_settings_unittest.cc
blob72e769a4194d392294f8a60bb805bcac8e50abd5
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/login_settings.h"
7 #include <cstddef>
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webrtc/libjingle/xmpp/xmppclientsettings.h"
12 namespace notifier {
14 namespace {
16 const char kAuthMechanism[] = "auth_mechanism";
18 class LoginSettingsTest : public ::testing::Test {
19 protected:
20 LoginSettingsTest() {
21 servers_.push_back(
22 ServerInformation(
23 net::HostPortPair("default.com", 100),
24 DOES_NOT_SUPPORT_SSLTCP));
27 ServerList servers_;
30 TEST_F(LoginSettingsTest, Basic) {
31 const LoginSettings login_settings(buzz::XmppClientSettings(),
32 NULL,
33 servers_,
34 false /* try_ssltcp_first */,
35 kAuthMechanism);
36 EXPECT_EQ(base::Time(), login_settings.GetRedirectExpirationForTest());
37 const ServerList& servers = login_settings.GetServers();
38 ASSERT_EQ(servers_.size(), servers.size());
39 for (size_t i = 0; i < servers.size(); ++i) {
40 EXPECT_TRUE(servers[i].Equals(servers_[i]));
44 TEST_F(LoginSettingsTest, Redirect) {
45 LoginSettings login_settings(buzz::XmppClientSettings(),
46 NULL,
47 servers_,
48 false /* try_ssltcp_first */,
49 kAuthMechanism);
50 const ServerInformation redirect_server(
51 net::HostPortPair("redirect.com", 200),
52 SUPPORTS_SSLTCP);
53 login_settings.SetRedirectServer(redirect_server);
56 const ServerList& servers =
57 login_settings.GetServersForTimeForTest(
58 login_settings.GetRedirectExpirationForTest() -
59 base::TimeDelta::FromMilliseconds(1));
60 ASSERT_EQ(servers_.size(), 1u);
61 EXPECT_TRUE(servers[0].Equals(redirect_server));
65 const ServerList& servers =
66 login_settings.GetServersForTimeForTest(
67 login_settings.GetRedirectExpirationForTest());
68 ASSERT_EQ(servers_.size(), servers.size());
69 for (size_t i = 0; i < servers.size(); ++i) {
70 EXPECT_TRUE(servers[i].Equals(servers_[i]));
75 } // namespace
77 } // namespace notifier