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..0d0c74f12346864aee21fad9d1a7dff30cf93739 100644 |
--- a/chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
+++ b/chrome/browser/sync/test/integration/wifi_credentials_helper.cc |
@@ -10,13 +10,17 @@ |
#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; |
@@ -25,11 +29,42 @@ namespace wifi_credentials_helper { |
namespace { |
+bool SetupClientForProfile(Profile* profile) { |
+#if defined(OS_CHROMEOS) |
+ return |
+ wifi_credentials_helper::chromeos::SetupClientForProfileChromeOs(profile); |
+#else |
+ NOTREACHED(); |
pneubeck (no reviews)
2015/01/30 14:38:45
note that this does not crash on release builds (t
mukesh agrawal
2015/01/30 22:28:14
Thanks for the info. I wasn't aware of that, but I
|
+ 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) |
+ wifi_credentials_helper::chromeos::AddWifiCredentialToProfileChromeOs( |
+ profile, credential); |
+#else |
+ NOTREACHED(); |
+#endif |
+} |
+ |
WifiCredentialSet GetWifiCredentialsForProfile(const Profile* profile) { |
#if defined(OS_CHROMEOS) |
- return GetWifiCredentialsForProfileChromeOs(profile); |
+ return wifi_credentials_helper::chromeos:: |
+ GetWifiCredentialsForProfileChromeOs(profile); |
#else |
- NOTIMPLEMENTED(); |
+ NOTREACHED(); |
return WifiCredential::MakeSet(); |
#endif |
} |
@@ -43,7 +78,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 +96,26 @@ bool CredentialsMatch(const WifiCredentialSet& a_credentials, |
} // namespace |
+void SetUp() { |
+#if defined(OS_CHROMEOS) |
+ return wifi_credentials_helper::chromeos::SetUpChromeOs(); |
+#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 +147,26 @@ bool AllProfilesMatch() { |
return true; |
} |
+scoped_ptr<WifiCredential> MakeWifiCredential(const std::string& ssid, |
+ WifiSecurityClass security_class, |
+ const std::string& passphrase) { |
+ return WifiCredential::Create(WifiCredential::MakeSsidBytesForTest(ssid), |
+ security_class, |
+ passphrase); |
+} |
+ |
+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 |