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

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

Issue 8586030: Added ConfigurationPolicyProvider::RefreshPolicies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed LoginUtilsTest Created 9 years, 1 month 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/policy/configuration_policy_provider_test.cc
diff --git a/chrome/browser/policy/configuration_policy_provider_test.cc b/chrome/browser/policy/configuration_policy_provider_test.cc
index 6997e6140c7d42665c937a36890add40020906aa..5dadff7b042a040403490d526d137bbd9d0721e4 100644
--- a/chrome/browser/policy/configuration_policy_provider_test.cc
+++ b/chrome/browser/policy/configuration_policy_provider_test.cc
@@ -9,8 +9,13 @@
#include "chrome/browser/policy/asynchronous_policy_loader.h"
#include "chrome/browser/policy/asynchronous_policy_provider.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
+#include "chrome/browser/policy/mock_configuration_policy_provider.h"
#include "chrome/browser/policy/policy_map.h"
#include "policy/policy_constants.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using ::testing::Mock;
+using ::testing::_;
namespace policy {
@@ -56,6 +61,9 @@ void ConfigurationPolicyProviderTest::SetUp() {
provider_.reset(
test_harness_->CreateProvider(&test_policy_definitions::kList));
+ // Some providers do a reload on init. Make sure any notifications generated
+ // are fired now.
+ loop_.RunAllPending();
PolicyMap policy_map;
EXPECT_TRUE(provider_->Provide(&policy_map));
@@ -76,7 +84,7 @@ void ConfigurationPolicyProviderTest::CheckValue(
base::Closure install_value) {
// Install the value, reload policy and check the provider for the value.
install_value.Run();
- provider_->ForceReload();
+ provider_->RefreshPolicies();
loop_.RunAllPending();
PolicyMap policy_map;
EXPECT_TRUE(provider_->Provide(&policy_map));
@@ -86,7 +94,7 @@ void ConfigurationPolicyProviderTest::CheckValue(
}
TEST_P(ConfigurationPolicyProviderTest, Empty) {
- provider_->ForceReload();
+ provider_->RefreshPolicies();
loop_.RunAllPending();
PolicyMap policy_map;
EXPECT_TRUE(provider_->Provide(&policy_map));
@@ -140,4 +148,34 @@ TEST_P(ConfigurationPolicyProviderTest, StringListValue) {
&expected_value));
}
+TEST_P(ConfigurationPolicyProviderTest, RefreshPolicies) {
+ PolicyMap policy_map;
+ EXPECT_TRUE(provider_->Provide(&policy_map));
+ EXPECT_EQ(0U, policy_map.size());
+
+ // OnUpdatePolicy is called even when there are no changes.
+ MockConfigurationPolicyObserver observer;
+ ConfigurationPolicyObserverRegistrar registrar;
+ registrar.Init(provider_.get(), &observer);
+ EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1);
+ provider_->RefreshPolicies();
+ loop_.RunAllPending();
+ Mock::VerifyAndClearExpectations(&observer);
+
+ EXPECT_TRUE(provider_->Provide(&policy_map));
+ EXPECT_EQ(0U, policy_map.size());
+
+ // OnUpdatePolicy is called when there are changes.
+ test_harness_->InstallStringPolicy(test_policy_definitions::kKeyString,
+ "value");
+ EXPECT_CALL(observer, OnUpdatePolicy(provider_.get())).Times(1);
+ provider_->RefreshPolicies();
+ loop_.RunAllPending();
+ Mock::VerifyAndClearExpectations(&observer);
+
+ policy_map.Clear();
+ EXPECT_TRUE(provider_->Provide(&policy_map));
+ EXPECT_EQ(1U, policy_map.size());
+}
+
} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698