1 /*
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 
11 #include "p2p/base/ice_credentials_iterator.h"
12 
13 #include <vector>
14 
15 #include "test/gtest.h"
16 
17 using cricket::IceCredentialsIterator;
18 using cricket::IceParameters;
19 
TEST(IceCredentialsIteratorTest,GetEmpty)20 TEST(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 
TEST(IceCredentialsIteratorTest,GetOne)27 TEST(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 
TEST(IceCredentialsIteratorTest,GetTwo)37 TEST(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 }
49