OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media/router/discovery/discovery_network_list.h" | 5 #include "chrome/browser/media/router/discovery/discovery_network_list.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
| 11 #include <iostream> // XXX |
| 12 |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
12 | 14 |
13 TEST(DiscoveryNetworkListTest, GetDiscoveryNetworkInfoList) { | 15 TEST(DiscoveryNetworkListTest, GetDiscoveryNetworkInfoList) { |
14 auto network_ids = GetDiscoveryNetworkInfoList(); | 16 auto network_ids = GetDiscoveryNetworkInfoList(); |
15 for (const auto& network_id : network_ids) { | 17 for (const auto& network_id : network_ids) { |
16 // We can't mock out the OS layer used by GetDiscoveryNetworkIdList, so | 18 // We can't mock out the OS layer used by GetDiscoveryNetworkIdList, so |
17 // instead just check that each returned interface name is non-empty. | 19 // instead just check that each returned interface name is non-empty. |
| 20 std::cout << network_id.name << ": " << network_id.network_id << std::endl; |
18 EXPECT_FALSE(network_id.name.empty()); | 21 EXPECT_FALSE(network_id.name.empty()); |
19 } | 22 } |
20 | 23 |
21 // Also check that at most one ID is returned per interface name. | 24 // Also check that at most one ID is returned per interface name. |
22 std::set<std::string> interface_name_set; | 25 std::set<std::string> interface_name_set; |
23 std::transform(begin(network_ids), end(network_ids), | 26 std::transform(begin(network_ids), end(network_ids), |
24 std::insert_iterator<std::set<std::string>>{ | 27 std::insert_iterator<std::set<std::string>>{ |
25 interface_name_set, end(interface_name_set)}, | 28 interface_name_set, end(interface_name_set)}, |
26 [](const DiscoveryNetworkInfo& network_info) { | 29 [](const DiscoveryNetworkInfo& network_info) { |
27 return network_info.name; | 30 return network_info.name; |
(...skipping 20 matching lines...) Expand all Loading... |
48 {"wlan1", "ssid0"}, {"eth0", "de:ad:be:ef:00:11"}, {"wlan0", "ssid0"}, | 51 {"wlan1", "ssid0"}, {"eth0", "de:ad:be:ef:00:11"}, {"wlan0", "ssid0"}, |
49 }); | 52 }); |
50 std::vector<DiscoveryNetworkInfo> sorted_network_info({ | 53 std::vector<DiscoveryNetworkInfo> sorted_network_info({ |
51 {"eth0", "de:ad:be:ef:00:11"}, {"wlan1", "ssid0"}, {"wlan0", "ssid0"}, | 54 {"eth0", "de:ad:be:ef:00:11"}, {"wlan1", "ssid0"}, {"wlan0", "ssid0"}, |
52 }); | 55 }); |
53 | 56 |
54 StableSortDiscoveryNetworkInfo(network_info.begin(), network_info.end()); | 57 StableSortDiscoveryNetworkInfo(network_info.begin(), network_info.end()); |
55 | 58 |
56 EXPECT_EQ(sorted_network_info, network_info); | 59 EXPECT_EQ(sorted_network_info, network_info); |
57 } | 60 } |
OLD | NEW |