This source file includes following definitions.
- TEST_F
- TEST_F
#include "jingle/notifier/communicator/login_settings.h"
#include <cstddef>
#include "talk/xmpp/xmppclientsettings.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace notifier {
namespace {
const char kAuthMechanism[] = "auth_mechanism";
class LoginSettingsTest : public ::testing::Test {
protected:
LoginSettingsTest() {
servers_.push_back(
ServerInformation(
net::HostPortPair("default.com", 100),
DOES_NOT_SUPPORT_SSLTCP));
}
ServerList servers_;
};
TEST_F(LoginSettingsTest, Basic) {
const LoginSettings login_settings(buzz::XmppClientSettings(),
NULL,
servers_,
false ,
kAuthMechanism);
EXPECT_EQ(base::Time(), login_settings.GetRedirectExpirationForTest());
const ServerList& servers = login_settings.GetServers();
ASSERT_EQ(servers_.size(), servers.size());
for (size_t i = 0; i < servers.size(); ++i) {
EXPECT_TRUE(servers[i].Equals(servers_[i]));
}
}
TEST_F(LoginSettingsTest, Redirect) {
LoginSettings login_settings(buzz::XmppClientSettings(),
NULL,
servers_,
false ,
kAuthMechanism);
const ServerInformation redirect_server(
net::HostPortPair("redirect.com", 200),
SUPPORTS_SSLTCP);
login_settings.SetRedirectServer(redirect_server);
{
const ServerList& servers =
login_settings.GetServersForTimeForTest(
login_settings.GetRedirectExpirationForTest() -
base::TimeDelta::FromMilliseconds(1));
ASSERT_EQ(servers_.size(), 1u);
EXPECT_TRUE(servers[0].Equals(redirect_server));
}
{
const ServerList& servers =
login_settings.GetServersForTimeForTest(
login_settings.GetRedirectExpirationForTest());
ASSERT_EQ(servers_.size(), servers.size());
for (size_t i = 0; i < servers.size(); ++i) {
EXPECT_TRUE(servers[i].Equals(servers_[i]));
}
}
}
}
}