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

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

Issue 8804021: Proper management for policy-configured networks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years 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') | no next file » | 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 2ef0734c6cb5a555e915bb7c6c65c8425f8e112e..6ce1f7ab7c7c95c39a2c008eb3ebd89d34853e11 100644
--- a/chrome/browser/policy/network_configuration_updater_unittest.cc
+++ b/chrome/browser/policy/network_configuration_updater_unittest.cc
@@ -20,6 +20,24 @@ static const char kFakeONC[] = "{ \"GUID\": \"1234\" }";
class NetworkConfigurationUpdaterTest
: public testing::TestWithParam<ConfigurationPolicyType> {
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;
+ }
+ }
+
chromeos::MockNetworkLibrary network_library_;
MockConfigurationPolicyProvider provider_;
};
@@ -27,8 +45,9 @@ class NetworkConfigurationUpdaterTest
TEST_P(NetworkConfigurationUpdaterTest, InitialUpdate) {
provider_.AddPolicy(GetParam(), Value::CreateStringValue(kFakeONC));
- EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _, _))
- .WillRepeatedly(Return(true));
+ EXPECT_CALL(network_library_,
+ LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
+ .WillOnce(Return(true));
NetworkConfigurationUpdater updater(&provider_, &network_library_);
Mock::VerifyAndClearExpectations(&network_library_);
@@ -38,20 +57,24 @@ TEST_P(NetworkConfigurationUpdaterTest, PolicyChange) {
NetworkConfigurationUpdater updater(&provider_, &network_library_);
// We should update if policy changes.
- EXPECT_CALL(network_library_, LoadOncNetworks(kFakeONC, "", _, _))
+ EXPECT_CALL(network_library_,
+ LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
.WillOnce(Return(true));
provider_.AddPolicy(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, "", _, _))
+ EXPECT_CALL(network_library_,
+ LoadOncNetworks(kFakeONC, "", TypeToONCSource(GetParam()), _))
.Times(0);
provider_.NotifyPolicyUpdated();
Mock::VerifyAndClearExpectations(&network_library_);
// Another update is expected if the policy goes away.
- EXPECT_CALL(network_library_, LoadOncNetworks("", "", _, _))
+ EXPECT_CALL(network_library_,
+ LoadOncNetworks(NetworkConfigurationUpdater::kEmptyConfiguration,
+ "", TypeToONCSource(GetParam()), _))
.WillOnce(Return(true));
provider_.RemovePolicy(GetParam());
provider_.NotifyPolicyUpdated();
« no previous file with comments | « chrome/browser/policy/network_configuration_updater.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698