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(DiscoveryNetworkListTest, GetDiscoveryNetworkInfoList) { | |
14 auto network_ids = GetDiscoveryNetworkInfoList(); | |
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.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>{}; | |
imcheng
2017/05/26 23:49:01
Can this just be std::set<std::string> interface_n
btolsch
2017/05/30 09:54:30
Done.
| |
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 DiscoveryNetworkInfo& network_info) { | |
28 return network_info.name; | |
29 }); | |
30 | |
31 EXPECT_EQ(interface_name_set.size(), network_ids.size()); | |
32 } | |
OLD | NEW |