OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2017 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. |
| 4 |
| 5 #include "chrome/browser/media/router/discovery/discovery_network_list.h" |
| 6 |
| 7 #include <algorithm> |
| 8 #include <iterator> |
| 9 #include <set> |
| 10 |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 TEST(DiscoveryNetworkList, GetDiscoveryNetworkIdList) { |
| 14 auto network_ids = GetDiscoveryNetworkIdList(); |
| 15 for (const auto& network_id : network_ids) { |
| 16 // We can't mock out the OS layer used by GetDiscoveryNetworkIdList, so |
| 17 // instead just check that each returned interface name and ID is non-empty. |
| 18 EXPECT_FALSE(network_id.interface_name.empty()); |
| 19 EXPECT_FALSE(network_id.network_id.empty()); |
| 20 } |
| 21 |
| 22 // Also check that at most one ID is returned per interface name. |
| 23 auto interface_name_set = std::set<std::string>{}; |
| 24 std::transform(begin(network_ids), end(network_ids), |
| 25 std::insert_iterator<std::set<std::string>>{ |
| 26 interface_name_set, end(interface_name_set)}, |
| 27 [](const DiscoveryNetworkId& network_id) { |
| 28 return network_id.interface_name; |
| 29 }); |
| 30 |
| 31 EXPECT_EQ(interface_name_set.size(), network_ids.size()); |
| 32 } |
OLD | NEW |