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

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

Issue 5562002: Refactor FileBasedPolicyProvider, introduce AsynchronousPolicyProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback Created 10 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
Index: chrome/browser/policy/asynchronous_policy_provider_unittest.cc
diff --git a/chrome/browser/policy/asynchronous_policy_provider_unittest.cc b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5d2c51e41337bbe5c1dc2f5fc87aca83fcf8d474
--- /dev/null
+++ b/chrome/browser/policy/asynchronous_policy_provider_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 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.
+
+#include "base/message_loop.h"
Mattias Nissler (ping if slow) 2010/12/06 10:26:20 Don't need this header, since you get loop_ from t
danno 2010/12/06 14:05:12 Done.
+#include "chrome/browser/policy/asynchronous_policy_loader.h"
+#include "chrome/browser/policy/asynchronous_policy_provider.h"
+#include "chrome/browser/policy/asynchronous_policy_test_base.h"
+#include "chrome/browser/policy/configuration_policy_pref_store.h"
+#include "chrome/browser/policy/mock_configuration_policy_store.h"
+#include "chrome/common/policy_constants.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::_;
+using ::testing::InSequence;
+using ::testing::Return;
+
+namespace policy {
+
+TEST_F(AsynchronousPolicyTestBase, Provide) {
+ InSequence s;
+ DictionaryValue* policies = new DictionaryValue();
+ policies->SetBoolean(policy::key::kSyncDisabled, true);
+ EXPECT_CALL(*delegate_, Load()).WillOnce(Return(policies));
+ EXPECT_CALL(*store_, Apply(policy::kPolicySyncDisabled, _)).Times(1);
+ provider_.reset(new AsynchronousPolicyProvider(
+ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
+ new AsynchronousPolicyLoader(delegate_.release())));
+ provider_->Provide(store_.get());
+}
+
+TEST_F(AsynchronousPolicyTestBase, ProvideAfterRefresh) {
+ InSequence s;
+ DictionaryValue* original_policies = new DictionaryValue();
+ original_policies->SetBoolean(policy::key::kSyncDisabled, true);
+ EXPECT_CALL(*delegate_, Load()).WillOnce(Return(original_policies));
+ DictionaryValue* refresh_policies = new DictionaryValue();
+ refresh_policies->SetBoolean(
+ policy::key::kJavascriptEnabled,
+ true);
+ EXPECT_CALL(*delegate_, Load()).WillOnce(Return(refresh_policies));
+ EXPECT_CALL(*store_, Apply(policy::kPolicyJavascriptEnabled, _)).Times(1);
+ AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader(
+ delegate_.release());
+ provider_.reset(new AsynchronousPolicyProvider(
+ ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
+ loader));
+ loop_.RunAllPending();
+ loader->Reload();
+ loop_.RunAllPending();
+ provider_->Provide(store_.get());
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698