Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 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 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 11 | #include "p2p/base/ice_credentials_iterator.h" |
| 12 | |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 13 | #include <vector> |
| 14 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 15 | #include "test/gtest.h" |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 16 | |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 17 | using cricket::IceCredentialsIterator; |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 18 | using cricket::IceParameters; |
Jonas Oreland | 1cd39fa | 2018-10-11 07:47:12 +0200 | [diff] [blame] | 19 | |
| 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 | |
| 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 | |
| 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 | } |