Index: chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
diff --git a/chrome/browser/sync/test/integration/wifi_credentials_helper.cc b/chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
index d29765f1cb848db10e2b51b8fe725d0b044b33e3..3f4dfb9184fd839f48df38b7e4f891d8f67ac8ca 100644 |
--- a/chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
+++ b/chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
@@ -5,18 +5,23 @@ |
#include "chrome/browser/sync/test/integration/wifi_credentials_helper.h" |
#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/strings/string_number_conversions.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
#include "chrome/browser/sync/test/integration/sync_test.h" |
#include "components/wifi_sync/wifi_credential.h" |
-#include "components/wifi_sync/wifi_security_class.h" |
+#include "components/wifi_sync/wifi_credential_syncable_service.h" |
+#include "components/wifi_sync/wifi_credential_syncable_service_factory.h" |
#if defined(OS_CHROMEOS) |
#include "chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.h" |
#endif |
using wifi_sync::WifiCredential; |
+using wifi_sync::WifiCredentialSyncableService; |
+using wifi_sync::WifiCredentialSyncableServiceFactory; |
+using wifi_sync::WifiSecurityClass; |
using sync_datatype_helper::test; |
using WifiCredentialSet = wifi_sync::WifiCredential::CredentialSet; |
@@ -24,12 +29,39 @@ using WifiCredentialSet = wifi_sync::WifiCredential::CredentialSet; |
namespace wifi_credentials_helper { |
namespace { |
stevenjb
2015/01/28 21:29:43
WS
mukesh agrawal
2015/01/28 22:55:11
Done.
|
+bool SetupClientForProfile(Profile* profile) { |
+#if defined(OS_CHROMEOS) |
+ return SetupClientForProfileChromeOs(profile); |
+#else |
+ NOTREACHED(); |
+ return false; |
+#endif |
+} |
+ |
+WifiCredentialSyncableService* GetServiceForBrowserContext( |
+ content::BrowserContext* context) { |
+ return WifiCredentialSyncableServiceFactory::GetForBrowserContext( |
+ context); |
+} |
+ |
+WifiCredentialSyncableService* GetServiceForProfile(int profile_index) { |
+ return GetServiceForBrowserContext(test()->GetProfile(profile_index)); |
+} |
+ |
+void AddWifiCredentialToProfile( |
+ Profile* profile, const WifiCredential& credential) { |
+#if defined(OS_CHROMEOS) |
+ AddWifiCredentialToProfileChromeOs(profile, credential); |
+#else |
+ NOTREACHED(); |
+#endif |
+} |
WifiCredentialSet GetWifiCredentialsForProfile(const Profile* profile) { |
#if defined(OS_CHROMEOS) |
return GetWifiCredentialsForProfileChromeOs(profile); |
#else |
- NOTIMPLEMENTED(); |
+ NOTREACHED(); |
return WifiCredential::MakeSet(); |
#endif |
} |
@@ -43,7 +75,7 @@ bool CredentialsMatch(const WifiCredentialSet& a_credentials, |
return false; |
} |
- for (const auto &credential : a_credentials) { |
+ for (const WifiCredential& credential : a_credentials) { |
if (b_credentials.find(credential) == b_credentials.end()) { |
LOG(ERROR) |
<< "Network from a not found in b. " |
@@ -61,6 +93,26 @@ bool CredentialsMatch(const WifiCredentialSet& a_credentials, |
} // namespace |
+void SetUp() { |
+#if defined(OS_CHROMEOS) |
+ return SetUpChromeOs(); |
stevenjb
2015/01/28 21:29:43
This is a little confusing since it is not defined
mukesh agrawal
2015/01/28 22:55:11
Done.
|
+#else |
+ NOTREACHED(); |
+#endif |
+} |
+ |
+bool SetupClients() { |
+ if (!SetupClientForProfile(test()->verifier())) |
+ return false; |
+ |
+ for (int i = 0; i < test()->num_clients(); ++i) { |
+ if (!SetupClientForProfile(test()->GetProfile(i))) |
+ return false; |
+ } |
+ |
+ return true; |
+} |
+ |
bool VerifierIsEmpty() { |
return GetWifiCredentialsForProfile(test()->verifier()).empty(); |
} |
@@ -92,4 +144,30 @@ bool AllProfilesMatch() { |
return true; |
} |
+WifiCredential MakeWifiCredential(const std::string& ssid, |
+ WifiSecurityClass security_class, |
+ const std::string& passphrase) { |
+ scoped_ptr<WifiCredential> credential = |
+ WifiCredential::Create( |
+ WifiCredential::MakeSsidBytesForTest(ssid), |
+ security_class, |
+ passphrase); |
+ CHECK(credential); |
+ return *credential; |
stevenjb
2015/01/28 21:29:43
The implict copy here is confusing. I would have M
mukesh agrawal
2015/01/28 22:55:11
Done.
|
+} |
+ |
+void AddWifiCredential(int profile_index, |
+ const std::string& sync_id, |
+ const WifiCredential& credential) { |
+ AddWifiCredentialToProfile(test()->GetProfile(profile_index), credential); |
+ if (test()->use_verifier()) |
+ AddWifiCredentialToProfile(test()->verifier(), credential); |
+ |
+ // TODO(quiche): Remove this, once we have plumbing to route |
+ // NetworkConfigurationObserver events to |
+ // WifiCredentialSyncableService instances. |
+ GetServiceForProfile(profile_index) |
+ ->AddToSyncedNetworks(sync_id, credential); |
+} |
+ |
} // namespace wifi_credentials_helper |