Chromium Code Reviews| Index: chrome/browser/media/router/discovery/discovery_network_list_unittest.cc |
| diff --git a/chrome/browser/media/router/discovery/discovery_network_list_unittest.cc b/chrome/browser/media/router/discovery/discovery_network_list_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..22b19c47d7e7366ba615dbdf75117eb083db40cf |
| --- /dev/null |
| +++ b/chrome/browser/media/router/discovery/discovery_network_list_unittest.cc |
| @@ -0,0 +1,32 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/media/router/discovery/discovery_network_list.h" |
| + |
| +#include <algorithm> |
| +#include <iterator> |
| +#include <set> |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| + |
| +TEST(DiscoveryNetworkListTest, GetDiscoveryNetworkInfoList) { |
| + auto network_ids = GetDiscoveryNetworkInfoList(); |
| + for (const auto& network_id : network_ids) { |
| + // We can't mock out the OS layer used by GetDiscoveryNetworkIdList, so |
| + // instead just check that each returned interface name and ID is non-empty. |
| + EXPECT_FALSE(network_id.name.empty()); |
| + EXPECT_FALSE(network_id.network_id.empty()); |
| + } |
| + |
| + // Also check that at most one ID is returned per interface name. |
| + 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.
|
| + std::transform(begin(network_ids), end(network_ids), |
| + std::insert_iterator<std::set<std::string>>{ |
| + interface_name_set, end(interface_name_set)}, |
| + [](const DiscoveryNetworkInfo& network_info) { |
| + return network_info.name; |
| + }); |
| + |
| + EXPECT_EQ(interface_name_set.size(), network_ids.size()); |
| +} |