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

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

Issue 10500013: Delete old policy code after AsyncPolicyLoader refactor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebased Created 8 years, 6 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/file_based_policy_provider.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/file_based_policy_provider_unittest.cc
diff --git a/chrome/browser/policy/file_based_policy_provider_unittest.cc b/chrome/browser/policy/file_based_policy_provider_unittest.cc
deleted file mode 100644
index 8699f68f07278d40b5782d65236917a229bb2acb..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/file_based_policy_provider_unittest.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// 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.
-
-#include "base/values.h"
-#include "chrome/browser/policy/asynchronous_policy_loader.h"
-#include "chrome/browser/policy/asynchronous_policy_test_base.h"
-#include "chrome/browser/policy/configuration_policy_pref_store.h"
-#include "chrome/browser/policy/configuration_policy_provider.h"
-#include "chrome/browser/policy/file_based_policy_provider.h"
-#include "chrome/browser/policy/mock_configuration_policy_provider.h"
-#include "chrome/browser/policy/policy_bundle.h"
-#include "chrome/browser/policy/policy_map.h"
-#include "policy/policy_constants.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using testing::InSequence;
-using testing::Return;
-using testing::_;
-
-namespace policy {
-
-class FileBasedPolicyProviderDelegateMock
- : public FileBasedPolicyProvider::ProviderDelegate {
- public:
- FileBasedPolicyProviderDelegateMock()
- : FileBasedPolicyProvider::ProviderDelegate(FilePath()) {}
-
- // Load() returns a scoped_ptr<PolicyBundle> but it can't be mocked because
- // scoped_ptr is moveable but not copyable. This override forwards the
- // call to MockLoad() which returns a PolicyBundle*, and returns a copy
- // wrapped in a passed scoped_ptr.
- virtual scoped_ptr<PolicyBundle> Load() OVERRIDE {
- scoped_ptr<PolicyBundle> bundle;
- PolicyBundle* loaded = MockLoad();
- if (loaded) {
- bundle.reset(new PolicyBundle());
- bundle->CopyFrom(*loaded);
- }
- return bundle.Pass();
- }
-
- MOCK_METHOD0(MockLoad, PolicyBundle*());
- MOCK_METHOD0(GetLastModification, base::Time());
-};
-
-TEST_F(AsynchronousPolicyTestBase, ProviderInit) {
- base::Time last_modified;
- FileBasedPolicyProviderDelegateMock* provider_delegate =
- new FileBasedPolicyProviderDelegateMock();
- EXPECT_CALL(*provider_delegate, GetLastModification()).WillRepeatedly(
- Return(last_modified));
- InSequence s;
- PolicyBundle empty_bundle;
- EXPECT_CALL(*provider_delegate, MockLoad()).WillOnce(Return(&empty_bundle));
- PolicyBundle bundle;
- bundle.Get(POLICY_DOMAIN_CHROME, "")
- .Set(key::kSyncDisabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateBooleanValue(true));
- // A second call to Load gets triggered during the provider's construction
- // when the file watcher is initialized, since this file may have changed
- // between the initial load and creating watcher.
- EXPECT_CALL(*provider_delegate, MockLoad()).WillOnce(Return(&bundle));
- FileBasedPolicyProvider provider(GetChromePolicyDefinitionList(),
- provider_delegate);
- loop_.RunAllPending();
- EXPECT_TRUE(provider.policies().Equals(bundle));
-}
-
-TEST_F(AsynchronousPolicyTestBase, ProviderRefresh) {
- base::Time last_modified;
- FileBasedPolicyProviderDelegateMock* provider_delegate =
- new FileBasedPolicyProviderDelegateMock();
- EXPECT_CALL(*provider_delegate, GetLastModification()).WillRepeatedly(
- Return(last_modified));
- InSequence s;
- PolicyBundle empty_bundle;
- EXPECT_CALL(*provider_delegate, MockLoad()).WillOnce(Return(&empty_bundle));
- FileBasedPolicyProvider file_based_provider(GetChromePolicyDefinitionList(),
- provider_delegate);
- // A second call to Load gets triggered during the provider's construction
- // when the file watcher is initialized, since this file may have changed
- // between the initial load and creating watcher.
- EXPECT_CALL(*provider_delegate, MockLoad()).WillOnce(Return(&empty_bundle));
- loop_.RunAllPending();
- // A third and final call to Load is made by the explicit Reload. This
- // should be the one that provides the current policy.
- PolicyBundle bundle;
- bundle.Get(POLICY_DOMAIN_CHROME, "")
- .Set(key::kSyncDisabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
- base::Value::CreateBooleanValue(true));
- EXPECT_CALL(*provider_delegate, MockLoad()).WillOnce(Return(&bundle));
- MockConfigurationPolicyObserver observer;
- ConfigurationPolicyObserverRegistrar registrar;
- registrar.Init(&file_based_provider, &observer);
- EXPECT_CALL(observer, OnUpdatePolicy(&file_based_provider)).Times(1);
- file_based_provider.RefreshPolicies();
- loop_.RunAllPending();
- EXPECT_TRUE(file_based_provider.policies().Equals(bundle));
-}
-
-} // namespace policy
« no previous file with comments | « chrome/browser/policy/file_based_policy_provider.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698