shill: improve conformance with WiFiRoaming tests

This patch makes several changes to get shill passing more of
the WiFiRoaming suite. shill now passes 13 of the 18 tests.

Overview of changes:
- Clean up Services when their last Endpoint disappers.
- Make a new WiFi connection request pre-empt an existing one.
- Make Device::SelectService no-op if new service is same as old.
  (part of resolving crosbug.com/23703)
- Move auto-connect logic to its own function, and run that function
  in a deferred task (partly resolves crosbug.com/24276)
- Add a non-deferred variant of Service::Connect (part of resolving
  crosbug.com/24276).
- Have service sort order reflect whether or not services are
  connecting, failed, connectable, and configured for auto-connect.

BUG=chromium-os:24276,chromium-os:23223,chromium-os:22943,chromium-os:23703
TEST=WiFiRoaming, unit tests, manual

Manual testing: per https://gerrit.chromium.org/gerrit/12963

Collateral changes:
- updated TESTING
- added crosbug.com/24461 for problem with autotest and profiles
- declared some functions as const
- removed some useless comments

Change-Id: I36d6eb7108a377dbf409d3e5673deffb85c0633e
Reviewed-on: https://gerrit.chromium.org/gerrit/12687
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: mukesh agrawal <quiche@chromium.org>
diff --git a/wifi_endpoint.cc b/wifi_endpoint.cc
index 4234513..12d9e59 100644
--- a/wifi_endpoint.cc
+++ b/wifi_endpoint.cc
@@ -95,6 +95,30 @@
 }
 
 // static
+WiFiEndpoint *WiFiEndpoint::MakeOpenEndpoint(
+    const string &ssid, const string &bssid) {
+  map <string, ::DBus::Variant> args;
+  ::DBus::MessageIter writer;
+
+  writer = args[wpa_supplicant::kBSSPropertySSID].writer();
+  writer << vector<uint8_t>(ssid.begin(), ssid.end());
+
+  string bssid_nosep;
+  RemoveChars(bssid, ":", &bssid_nosep);
+  vector<uint8_t> bssid_bytes;
+  base::HexStringToBytes(bssid_nosep, &bssid_bytes);
+  writer = args[wpa_supplicant::kBSSPropertyBSSID].writer();
+  writer << bssid_bytes;
+
+  args[wpa_supplicant::kBSSPropertySignal].writer().append_int16(0);
+  args[wpa_supplicant::kBSSPropertyMode].writer().append_string(
+      wpa_supplicant::kNetworkModeInfrastructure);
+  // We indicate this is an open BSS by leaving out all security properties.
+
+  return new WiFiEndpoint(args);
+}
+
+// static
 const char *WiFiEndpoint::ParseMode(const string &mode_string) {
   if (mode_string == wpa_supplicant::kNetworkModeInfrastructure) {
     return flimflam::kModeManaged;