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

Unified Diff: chrome/browser/chromeos/extensions/networking_private_apitest.cc

Issue 12676017: Adding policy support to the new network configuration stack. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove policy initialized flags and wrap PolicyMaps with scoped_ptr. Created 7 years, 8 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/chromeos/extensions/networking_private_apitest.cc
diff --git a/chrome/browser/chromeos/extensions/networking_private_apitest.cc b/chrome/browser/chromeos/extensions/networking_private_apitest.cc
index 3013de57fb02eef1cce649deab8ab3b1c4412c34..2d87e086e789c917e5d2dc80c2592cf68a43cd25 100644
--- a/chrome/browser/chromeos/extensions/networking_private_apitest.cc
+++ b/chrome/browser/chromeos/extensions/networking_private_apitest.cc
@@ -10,11 +10,18 @@
#include "chrome/test/base/ui_test_utils.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
+#include "chromeos/dbus/shill_profile_client.h"
#include "chromeos/dbus/shill_service_client.h"
+#include "chromeos/network/managed_network_configuration_handler.h"
+#include "chromeos/network/onc/onc_constants.h"
+#include "chromeos/network/onc/onc_utils.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
+const char kSharedProfilePath[] = "/profile/default";
+const char kUserProfilePath[] = "/profile/chronos/shill";
+
class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest {
public:
// Whitelist the extension ID of the test extension.
@@ -61,6 +68,9 @@ class ExtensionNetworkingPrivateApiTest : public ExtensionApiTest {
flimflam::kTypeWifi, flimflam::kStateIdle,
add_to_watchlist);
service_test->SetServiceProperty("stub_wifi2",
+ flimflam::kGuidProperty,
+ base::StringValue("stub_wifi2"));
+ service_test->SetServiceProperty("stub_wifi2",
flimflam::kSecurityProperty,
base::StringValue(flimflam::kSecurityPsk));
service_test->SetServiceProperty("stub_wifi2",
@@ -142,6 +152,74 @@ IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest, SetProperties) {
}
IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
+ GetManagedProperties) {
+ ShillServiceClient::TestInterface* service_test =
+ DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
+ std::string uidata_blob =
stevenjb 2013/04/11 18:20:08 nit: const std::string
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
+ "{"
+ " \"user_settings\":"
+ " {"
+ " \"WiFi\": {"
+ " \"Passphrase\": \"top secret\","
+ " }"
+ " }"
+ "}";
stevenjb 2013/04/11 18:20:08 nit: maybe use less space by not putting {} on the
pneubeck (no reviews) 2013/04/15 12:16:24 Whitespace and linebreaks don't matter. But I'd pr
stevenjb 2013/04/15 17:38:54 +1
+ service_test->SetServiceProperty("stub_wifi2",
+ flimflam::kGuidProperty,
+ base::StringValue("stub_wifi2"));
+ service_test->SetServiceProperty("stub_wifi2",
+ flimflam::kUIDataProperty,
+ base::StringValue(uidata_blob));
+ service_test->SetServiceProperty("stub_wifi2",
+ flimflam::kProfileProperty,
+ base::StringValue(kUserProfilePath));
+ service_test->SetServiceProperty("stub_wifi2",
+ flimflam::kAutoConnectProperty,
+ base::FundamentalValue(false));
+
+ ShillProfileClient::TestInterface* profile_test =
+ DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface();
+
+ profile_test->AddService("stub_wifi2");
+
+ content::RunAllPendingInMessageLoop();
+
+ std::string user_policy_blob =
stevenjb 2013/04/11 18:20:08 Same nits as above.
pneubeck (no reviews) 2013/04/15 12:16:24 Done.
+ "{"
+ " \"NetworkConfigurations\": ["
+ " {"
+ " \"GUID\": \"stub_wifi2\","
+ " \"Type\": \"WiFi\","
+ " \"Name\": \"My WiFi Network\","
+ " \"WiFi\": {"
+ " \"Passphrase\": \"passphrase\","
+ " \"Recommended\": [ \"AutoConnect\", \"Passphrase\" ],"
+ " \"SSID\": \"stub_wifi2\","
+ " \"Security\": \"WPA-PSK\""
+ " }"
+ " }"
+ " ],"
+ " \"Certificates\": [],"
+ " \"Type\": \"UnencryptedConfiguration\""
+ "}";
+ scoped_ptr<base::DictionaryValue> user_policy =
+ onc::ReadDictionaryFromJson(user_policy_blob);
+ ManagedNetworkConfigurationHandler::Get()->SetPolicy(
+ onc::ONC_SOURCE_USER_POLICY,
+ *user_policy);
+
+ scoped_ptr<base::DictionaryValue> device_policy =
+ onc::ReadDictionaryFromJson(onc::kEmptyUnencryptedConfiguration);
+ ManagedNetworkConfigurationHandler::Get()->SetPolicy(
+ onc::ONC_SOURCE_DEVICE_POLICY,
+ *device_policy);
+
+ content::RunAllPendingInMessageLoop();
+
+ EXPECT_TRUE(RunNetworkingSubtest("getManagedProperties")) << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(ExtensionNetworkingPrivateApiTest,
OnNetworksChangedEventConnect) {
EXPECT_TRUE(RunNetworkingSubtest("onNetworksChangedEventConnect"))
<< message_;

Powered by Google App Engine
This is Rietveld 408576698