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

Unified Diff: chrome/browser/policy/network_configuration_updater_unittest.cc

Issue 9111022: Removed ConfigurationPolicyType and extended PolicyMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 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/policy/network_configuration_updater.cc ('k') | chrome/browser/policy/policy_error_map.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/network_configuration_updater_unittest.cc
diff --git a/chrome/browser/policy/network_configuration_updater_unittest.cc b/chrome/browser/policy/network_configuration_updater_unittest.cc
index 6ce1f7ab7c7c95c39a2c008eb3ebd89d34853e11..1b3f67dd79cf991bdf178f351c7fb4db2663054d 100644
--- a/chrome/browser/policy/network_configuration_updater_unittest.cc
+++ b/chrome/browser/policy/network_configuration_updater_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,6 +6,7 @@
#include "chrome/browser/chromeos/cros/mock_network_library.h"
#include "chrome/browser/policy/mock_configuration_policy_provider.h"
+#include "policy/policy_constants.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -18,24 +19,21 @@ namespace policy {
static const char kFakeONC[] = "{ \"GUID\": \"1234\" }";
class NetworkConfigurationUpdaterTest
- : public testing::TestWithParam<ConfigurationPolicyType> {
+ : public testing::TestWithParam<const char*> {
protected:
virtual void SetUp() OVERRIDE {
EXPECT_CALL(network_library_, LoadOncNetworks(_, "", _, _))
.WillRepeatedly(Return(true));
}
- // Maps configuration policy type to corresponding ONC source.
- static chromeos::NetworkUIData::ONCSource TypeToONCSource(
- ConfigurationPolicyType type) {
- switch (type) {
- case kPolicyDeviceOpenNetworkConfiguration:
- return chromeos::NetworkUIData::ONC_SOURCE_DEVICE_POLICY;
- case kPolicyOpenNetworkConfiguration:
- return chromeos::NetworkUIData::ONC_SOURCE_USER_POLICY;
- default:
- return chromeos::NetworkUIData::ONC_SOURCE_NONE;
- }
+ // Maps configuration policy name to corresponding ONC source.
+ static chromeos::NetworkUIData::ONCSource NameToONCSource(
+ const std::string& name) {
+ if (name == key::kDeviceOpenNetworkConfiguration)
+ return chromeos::NetworkUIData::ONC_SOURCE_DEVICE_POLICY;
+ if (name == key::kOpenNetworkConfiguration)
+ return chromeos::NetworkUIData::ONC_SOURCE_USER_POLICY;
+ return chromeos::NetworkUIData::ONC_SOURCE_NONE;
}
chromeos::MockNetworkLibrary network_library_;
@@ -43,10 +41,10 @@ class NetworkConfigurationUpdaterTest
};
TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) {
- provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
+ provider_.AddMandatoryPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
EXPECT_CALL(network_library_,
- LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
+ LoadOncNetworks(kFakeONC, "", NameToONCSource(GetParam()), _))
.WillOnce(Return(true));
NetworkConfigurationUpdater updater(&provider_, &network_library_);
@@ -58,15 +56,15 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
// We should update if policy changes.
EXPECT_CALL(network_library_,
- LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
+ LoadOncNetworks(kFakeONC, "", NameToONCSource(GetParam()), _))
.WillOnce(Return(true));
- provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
+ provider_.AddMandatoryPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
provider_.NotifyPolicyUpdated();
Mock::VerifyAndClearExpectations(&network_library_);
// No update if the set the same value again.
EXPECT_CALL(network_library_,
- LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
+ LoadOncNetworks(kFakeONC, "", NameToONCSource(GetParam()), _))
.Times(0);
provider_.NotifyPolicyUpdated();
Mock::VerifyAndClearExpectations(&network_library_);
@@ -74,7 +72,7 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
// Another update is expected if the policy goes away.
EXPECT_CALL(network_library_,
LoadOncNetworks(NetworkConfigurationUpdater::kEmptyConfiguration,
- "", TypeToONCSource(GetParam()), _))
+ "", NameToONCSource(GetParam()), _))
.WillOnce(Return(true));
provider_.RemovePolicy(GetParam());
provider_.NotifyPolicyUpdated();
@@ -84,7 +82,7 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
INSTANTIATE_TEST_CASE_P(
NetworkConfigurationUpdaterTestInstance,
NetworkConfigurationUpdaterTest,
- testing::Values(kPolicyDeviceOpenNetworkConfiguration,
- kPolicyOpenNetworkConfiguration));
+ testing::Values(key::kDeviceOpenNetworkConfiguration,
+ key::kOpenNetworkConfiguration));
} // namespace policy
« no previous file with comments | « chrome/browser/policy/network_configuration_updater.cc ('k') | chrome/browser/policy/policy_error_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698