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

Unified Diff: chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.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: 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
« no previous file with comments | « chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc
diff --git a/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc b/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc
index 8e5400247c21808abee5edcbbdf3b236208d1440..c50fa4af12579e5d9f26fb7edd1e619e62313b8c 100644
--- a/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc
+++ b/chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.cc
@@ -6,14 +6,22 @@
#include <string>
+#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "base/strings/stringprintf.h"
+#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/shill_profile_client.h"
+#include "chromeos/network/managed_network_configuration_handler.h"
#include "chromeos/network/network_handler.h"
-#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
+#include "components/onc/onc_constants.h"
#include "components/wifi_sync/network_state_helper_chromeos.h"
-#include "components/wifi_sync/wifi_security_class.h"
+#include "components/wifi_sync/wifi_config_delegate_factory_chromeos.h"
+
+using wifi_sync::WifiCredential;
using WifiCredentialSet = wifi_sync::WifiCredential::CredentialSet;
@@ -23,6 +31,15 @@ namespace {
const char kProfilePrefix[] = "/profile/";
+void DoNothingWithString(const std::string&) {}
+
+void LogCreateConfigurationFailure(
+ const std::string& debug_hint,
+ const std::string& /* network_config_error_message */,
+ scoped_ptr<base::DictionaryValue> /* network_config_error_data */) {
+ LOG(FATAL) << debug_hint;
+}
+
std::string ChromeOsUserHashForBrowserContext(
const content::BrowserContext& context) {
return context.GetPath().BaseName().value();
@@ -33,6 +50,23 @@ std::string ShillProfilePathForBrowserContext(
return kProfilePrefix + ChromeOsUserHashForBrowserContext(context);
}
+chromeos::ShillProfileClient::TestInterface*
+GetShillProfileClientTestInterface() {
+ DCHECK(chromeos::DBusThreadManager::Get()->GetShillProfileClient());
+ DCHECK(chromeos::DBusThreadManager::Get()->GetShillProfileClient()
+ ->GetTestInterface());
+ return chromeos::DBusThreadManager::Get()->GetShillProfileClient()
+ ->GetTestInterface();
+}
+
+chromeos::ManagedNetworkConfigurationHandler*
+GetManagedNetworkConfigurationHandler() {
+ DCHECK(chromeos::NetworkHandler::Get()
+ ->managed_network_configuration_handler());
+ return chromeos::NetworkHandler::Get()
+ ->managed_network_configuration_handler();
+}
+
chromeos::NetworkStateHandler* GetNetworkStateHandler() {
DCHECK(chromeos::NetworkHandler::Get()->network_state_handler());
return chromeos::NetworkHandler::Get()->network_state_handler();
@@ -40,6 +74,41 @@ chromeos::NetworkStateHandler* GetNetworkStateHandler() {
} // namespace
+void SetUpChromeOs() {
+ wifi_sync::WifiConfigDelegateFactoryChromeOs::GetInstance()
+ ->SetUseLoginState(false);
+}
+
+bool SetupClientForProfileChromeOs(const Profile* profile) {
+ DCHECK(profile);
+ GetShillProfileClientTestInterface()
+ ->AddProfile(ShillProfilePathForBrowserContext(*profile),
+ ChromeOsUserHashForBrowserContext(*profile));
+
+ const base::ListValue policy_network_configs;
+ const base::DictionaryValue policy_global_config;
+ GetManagedNetworkConfigurationHandler()
+ ->SetPolicy(onc::ONC_SOURCE_UNKNOWN,
+ ChromeOsUserHashForBrowserContext(*profile),
+ policy_network_configs,
+ policy_global_config);
+
+ return true;
+}
+
+void AddWifiCredentialToProfileChromeOs(
+ Profile* profile, const WifiCredential& credential) {
+ DCHECK(profile);
+ wifi_sync::CreateWifiNetworkInShillUserProfile(
+ GetManagedNetworkConfigurationHandler(),
+ ChromeOsUserHashForBrowserContext(*profile),
+ credential,
+ base::Bind(DoNothingWithString), // success_callback
+ base::Bind(LogCreateConfigurationFailure,
+ base::StringPrintf("Failed to add credential %s",
+ credential.ToString().c_str())));
+}
+
WifiCredentialSet GetWifiCredentialsForProfileChromeOs(const Profile* profile) {
DCHECK(profile);
return wifi_sync::GetWifiCredentialsForShillProfile(
« no previous file with comments | « chrome/browser/sync/test/integration/wifi_credentials_helper_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698