blob: 470efe3e4584c5117faecda29eba457d9038812f [file] [log] [blame]
Jonas Oreland1cd39fa2018-10-11 07:47:12 +02001/*
2 * Copyright 2018 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Jonas Olssona4d87372019-07-05 19:08:33 +020011#include "p2p/base/ice_credentials_iterator.h"
12
Jonas Oreland1cd39fa2018-10-11 07:47:12 +020013#include <vector>
14
Yves Gerey3e707812018-11-28 16:47:49 +010015#include "test/gtest.h"
Jonas Oreland1cd39fa2018-10-11 07:47:12 +020016
Jonas Oreland1cd39fa2018-10-11 07:47:12 +020017using cricket::IceCredentialsIterator;
Jonas Olssona4d87372019-07-05 19:08:33 +020018using cricket::IceParameters;
Jonas Oreland1cd39fa2018-10-11 07:47:12 +020019
20TEST(IceCredentialsIteratorTest, GetEmpty) {
21 std::vector<IceParameters> empty;
22 IceCredentialsIterator iterator(empty);
23 // Verify that we can get credentials even if input is empty.
24 IceParameters credentials1 = iterator.GetIceCredentials();
25}
26
27TEST(IceCredentialsIteratorTest, GetOne) {
28 std::vector<IceParameters> one = {
29 IceCredentialsIterator::CreateRandomIceCredentials()};
30 IceCredentialsIterator iterator(one);
31 EXPECT_EQ(iterator.GetIceCredentials(), one[0]);
32 auto random = iterator.GetIceCredentials();
33 EXPECT_NE(random, one[0]);
34 EXPECT_NE(random, iterator.GetIceCredentials());
35}
36
37TEST(IceCredentialsIteratorTest, GetTwo) {
38 std::vector<IceParameters> two = {
39 IceCredentialsIterator::CreateRandomIceCredentials(),
40 IceCredentialsIterator::CreateRandomIceCredentials()};
41 IceCredentialsIterator iterator(two);
42 EXPECT_EQ(iterator.GetIceCredentials(), two[1]);
43 EXPECT_EQ(iterator.GetIceCredentials(), two[0]);
44 auto random = iterator.GetIceCredentials();
45 EXPECT_NE(random, two[0]);
46 EXPECT_NE(random, two[1]);
47 EXPECT_NE(random, iterator.GetIceCredentials());
48}