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..98814796e30a91b882ba9dbd2f6207ff80867f47 |
--- /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) { |
mark a. foltz
2017/06/05 21:28:42
I am debating if this unit test is worth writing.
btolsch
2017/06/05 22:38:33
The first part makes sure that our code isn't retu
|
+ 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. |
+ std::set<std::string> interface_name_set; |
+ 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()); |
+} |