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

Unified Diff: chrome/browser/sync/test/integration/wifi_credentials_helper.cc

Issue 843483004: sync: add more integration tests for wifi_sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.3-syncable-service
Patch Set: address feedback from pneubeck, on PS6 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
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();
+ 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();
pneubeck (no reviews) 2015/01/31 10:26:40 Please remove the 'return'.
mukesh agrawal 2015/02/02 20:36:40 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 +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

Powered by Google App Engine
This is Rietveld 408576698