shill: Moves test-specific code into test source file.

Just a little cleanup.

BUG=None
TEST=unittest

Change-Id: Iea9a030d50a9269fc9fa8410e29d2ee48b36024b
Reviewed-on: https://gerrit.chromium.org/gerrit/57799
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
Commit-Queue: Wade Guthrie <wdg@chromium.org>
diff --git a/netlink_message_unittest.cc b/netlink_message_unittest.cc
index 9432e90..accca68 100644
--- a/netlink_message_unittest.cc
+++ b/netlink_message_unittest.cc
@@ -375,6 +375,60 @@
   }
 
  protected:
+  // Helper function to provide an array of scan frequencies from a message's
+  // NL80211_ATTR_SCAN_FREQUENCIES attribute.
+  static bool GetScanFrequenciesFromMessage(const Nl80211Message &message,
+                                            vector<uint32_t> *value) {
+    if (!value) {
+      LOG(ERROR) << "Null |value| parameter";
+      return false;
+    }
+
+    AttributeListConstRefPtr frequency_list;
+    if (!message.const_attributes()->ConstGetNestedAttributeList(
+        NL80211_ATTR_SCAN_FREQUENCIES, &frequency_list) || !frequency_list) {
+      LOG(ERROR) << "Couldn't get NL80211_ATTR_SCAN_FREQUENCIES attribute";
+      return false;
+    }
+
+    AttributeIdIterator freq_iter(*frequency_list);
+    value->clear();
+    for (; !freq_iter.AtEnd(); freq_iter.Advance()) {
+      uint32_t freq = 0;
+      if (frequency_list->GetU32AttributeValue(freq_iter.GetId(), &freq)) {
+        value->push_back(freq);
+      }
+    }
+    return true;
+  }
+
+  // Helper function to provide an array of SSIDs from a message's
+  // NL80211_ATTR_SCAN_SSIDS attribute.
+  static bool GetScanSsidsFromMessage(const Nl80211Message &message,
+                                      vector<string> *value) {
+    if (!value) {
+      LOG(ERROR) << "Null |value| parameter";
+      return false;
+    }
+
+    AttributeListConstRefPtr ssid_list;
+    if (!message.const_attributes()->ConstGetNestedAttributeList(
+        NL80211_ATTR_SCAN_SSIDS, &ssid_list) || !ssid_list) {
+      LOG(ERROR) << "Couldn't get NL80211_ATTR_SCAN_SSIDS attribute";
+      return false;
+    }
+
+    AttributeIdIterator ssid_iter(*ssid_list);
+    value->clear();
+    for (; !ssid_iter.AtEnd(); ssid_iter.Advance()) {
+      string ssid;
+      if (ssid_list->GetStringAttributeValue(ssid_iter.GetId(), &ssid)) {
+        value->push_back(ssid);
+      }
+    }
+    return true;
+  }
+
   NetlinkMessageFactory message_factory_;
 };
 
@@ -407,8 +461,7 @@
   // Make sure the scan frequencies in the attribute are the ones we expect.
   {
     vector<uint32_t>list;
-    EXPECT_TRUE(message->GetScanFrequenciesAttribute(
-        NL80211_ATTR_SCAN_FREQUENCIES, &list));
+    EXPECT_TRUE(GetScanFrequenciesFromMessage(*message, &list));
     EXPECT_EQ(list.size(), arraysize(kScanFrequencyTrigger));
     int i = 0;
     vector<uint32_t>::const_iterator j = list.begin();
@@ -421,8 +474,7 @@
 
   {
     vector<string> ssids;
-    EXPECT_TRUE(message->GetScanSsidsAttribute(NL80211_ATTR_SCAN_SSIDS,
-                                               &ssids));
+    EXPECT_TRUE(GetScanSsidsFromMessage(*message, &ssids));
     EXPECT_EQ(1, ssids.size());
     EXPECT_EQ(0, ssids[0].compare(""));  // Expect a single, empty SSID.
   }
@@ -460,8 +512,7 @@
   // Make sure the scan frequencies in the attribute are the ones we expect.
   {
     vector<uint32_t>list;
-    EXPECT_TRUE(message->GetScanFrequenciesAttribute(
-        NL80211_ATTR_SCAN_FREQUENCIES, &list));
+    EXPECT_TRUE(GetScanFrequenciesFromMessage(*message, &list));
     EXPECT_EQ(arraysize(kScanFrequencyResults), list.size());
     int i = 0;
     vector<uint32_t>::const_iterator j = list.begin();
@@ -474,8 +525,7 @@
 
   {
     vector<string> ssids;
-    EXPECT_TRUE(message->GetScanSsidsAttribute(NL80211_ATTR_SCAN_SSIDS,
-                                               &ssids));
+    EXPECT_TRUE(GetScanSsidsFromMessage(*message, &ssids));
     EXPECT_EQ(1, ssids.size());
     EXPECT_EQ(0, ssids[0].compare(""));  // Expect a single, empty SSID.
   }
diff --git a/nl80211_message.cc b/nl80211_message.cc
index 97d5419..8693c46 100644
--- a/nl80211_message.cc
+++ b/nl80211_message.cc
@@ -303,58 +303,6 @@
   return true;
 }
 
-// Helper function to provide a string for NL80211_ATTR_SCAN_FREQUENCIES.
-bool Nl80211Message::GetScanFrequenciesAttribute(
-    int id, vector<uint32_t> *value) const {
-  if (!value) {
-    LOG(ERROR) << "Null |value| parameter";
-    return false;
-  }
-
-  value->clear();
-
-  AttributeListConstRefPtr frequency_list;
-  if (!const_attributes()->ConstGetNestedAttributeList(
-      NL80211_ATTR_SCAN_FREQUENCIES, &frequency_list) || !frequency_list) {
-    LOG(ERROR) << "Couldn't get NL80211_ATTR_SCAN_FREQUENCIES attribute";
-    return false;
-  }
-
-  AttributeIdIterator freq_iter(*frequency_list);
-  for (; !freq_iter.AtEnd(); freq_iter.Advance()) {
-    uint32_t freq = 0;
-    if (frequency_list->GetU32AttributeValue(freq_iter.GetId(), &freq)) {
-      value->push_back(freq);
-    }
-  }
-  return true;
-}
-
-// Helper function to provide a string for NL80211_ATTR_SCAN_SSIDS.
-bool Nl80211Message::GetScanSsidsAttribute(
-    int id, vector<string> *value) const {
-  if (!value) {
-    LOG(ERROR) << "Null |value| parameter";
-    return false;
-  }
-
-  AttributeListConstRefPtr ssid_list;
-  if (!const_attributes()->ConstGetNestedAttributeList(
-      NL80211_ATTR_SCAN_SSIDS, &ssid_list) || !ssid_list) {
-    LOG(ERROR) << "Couldn't get NL80211_ATTR_SCAN_SSIDS attribute";
-    return false;
-  }
-
-  AttributeIdIterator ssid_iter(*ssid_list);
-  for (; !ssid_iter.AtEnd(); ssid_iter.Advance()) {
-    string ssid;
-    if (ssid_list->GetStringAttributeValue(ssid_iter.GetId(), &ssid)) {
-      value->push_back(ssid);
-    }
-  }
-  return true;
-}
-
 // static
 string Nl80211Message::StringFromReason(uint16_t status) {
   map<uint16_t, string>::const_iterator match;
diff --git a/nl80211_message.h b/nl80211_message.h
index 31e9723..62c8405 100644
--- a/nl80211_message.h
+++ b/nl80211_message.h
@@ -42,16 +42,6 @@
   uint32_t sequence_number() const { return sequence_number_; }
   void set_sequence_number(uint32_t seq) { sequence_number_ = seq; }
 
-  // TODO(wdg): This needs to be moved to AttributeScanFrequencies.
-  // Helper function to provide a vector of scan frequencies for attributes
-  // that contain them (such as NL80211_ATTR_SCAN_FREQUENCIES).
-  bool GetScanFrequenciesAttribute(int id, std::vector<uint32_t> *value) const;
-
-  // TODO(wdg): This needs to be moved to AttributeScanSSids.
-  // Helper function to provide a vector of SSIDs for attributes that contain
-  // them (such as NL80211_ATTR_SCAN_SSIDS).
-  bool GetScanSsidsAttribute(int id, std::vector<std::string> *value) const;
-
   // Returns a string representing the passed-in |status| or |reason|, the
   // value of which has been acquired from libnl (for example, from the
   // NL80211_ATTR_STATUS_CODE or NL80211_ATTR_REASON_CODE attribute).