Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2159)

Unified Diff: net/base/address_tracker_linux_unittest.cc

Issue 899573002: Add WiFi SSID getter to NetworkChangeNotifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/address_tracker_linux.cc ('k') | net/base/network_change_notifier.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/address_tracker_linux_unittest.cc
diff --git a/net/base/address_tracker_linux_unittest.cc b/net/base/address_tracker_linux_unittest.cc
index 1eba58fbe6af35aa9319129bfba5ac214be92baa..9b87434e73efa932d08eefd2eaa1cb5b30182b3c 100644
--- a/net/base/address_tracker_linux_unittest.cc
+++ b/net/base/address_tracker_linux_unittest.cc
@@ -21,6 +21,8 @@ namespace internal {
namespace {
const int kTestInterfaceTun = 123;
+const char kWiFiSSID[] = "TestWiFi";
+const char kInterfaceWithNoSSID[] = "wlan999";
char* TestGetInterfaceName(int interface_index, char* buf) {
if (interface_index == kTestInterfaceTun)
@@ -28,6 +30,10 @@ char* TestGetInterfaceName(int interface_index, char* buf) {
return strncpy(buf, "eth0", IFNAMSIZ);
}
+std::string TestGetInterfaceSSID(const std::string& ifname) {
+ return (ifname == kInterfaceWithNoSSID) ? "" : kWiFiSSID;
+}
+
} // namespace
typedef std::vector<char> Buffer;
@@ -552,6 +558,47 @@ TEST_F(AddressTrackerLinuxTest, NonTrackingModeInit) {
tracker.Init();
}
+TEST_F(AddressTrackerLinuxTest, ConnectionSSIDFromInterfaceList) {
+ NetworkInterfaceList list;
+ EXPECT_EQ(std::string(), AddressTrackerLinux::ConnectionSSIDFromInterfaceList(
+ list, TestGetInterfaceSSID));
+
+ NetworkInterface interface1;
+ interface1.name = "wlan0";
+ interface1.type = NetworkChangeNotifier::CONNECTION_WIFI;
+ list.push_back(interface1);
+ ASSERT_EQ(1u, list.size());
+ EXPECT_EQ(std::string(kWiFiSSID),
+ AddressTrackerLinux::ConnectionSSIDFromInterfaceList(
+ list, TestGetInterfaceSSID));
+
+ NetworkInterface interface2;
+ interface2.name = "wlan1";
+ interface2.type = NetworkChangeNotifier::CONNECTION_WIFI;
+ list.push_back(interface2);
+ ASSERT_EQ(2u, list.size());
+ EXPECT_EQ(std::string(kWiFiSSID),
+ AddressTrackerLinux::ConnectionSSIDFromInterfaceList(
+ list, TestGetInterfaceSSID));
+
+ NetworkInterface interface3;
+ interface3.name = kInterfaceWithNoSSID;
+ interface3.type = NetworkChangeNotifier::CONNECTION_WIFI;
+ list.push_back(interface3);
+ ASSERT_EQ(3u, list.size());
+ EXPECT_EQ(std::string(), AddressTrackerLinux::ConnectionSSIDFromInterfaceList(
+ list, TestGetInterfaceSSID));
+
+ list.pop_back();
+ NetworkInterface interface4;
+ interface4.name = "eth0";
+ interface4.type = NetworkChangeNotifier::CONNECTION_ETHERNET;
+ list.push_back(interface4);
+ ASSERT_EQ(3u, list.size());
+ EXPECT_EQ(std::string(), AddressTrackerLinux::ConnectionSSIDFromInterfaceList(
+ list, TestGetInterfaceSSID));
+}
+
} // namespace
} // namespace internal
« no previous file with comments | « net/base/address_tracker_linux.cc ('k') | net/base/network_change_notifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698