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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #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.
6 #include "chrome/browser/policy/asynchronous_policy_loader.h"
7 #include "chrome/browser/policy/asynchronous_policy_provider.h"
8 #include "chrome/browser/policy/asynchronous_policy_test_base.h"
9 #include "chrome/browser/policy/configuration_policy_pref_store.h"
10 #include "chrome/browser/policy/mock_configuration_policy_store.h"
11 #include "chrome/common/policy_constants.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 using ::testing::_;
16 using ::testing::InSequence;
17 using ::testing::Return;
18
19 namespace policy {
20
21 TEST_F(AsynchronousPolicyTestBase, Provide) {
22 InSequence s;
23 DictionaryValue* policies = new DictionaryValue();
24 policies->SetBoolean(policy::key::kSyncDisabled, true);
25 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(policies));
26 EXPECT_CALL(*store_, Apply(policy::kPolicySyncDisabled, _)).Times(1);
27 provider_.reset(new AsynchronousPolicyProvider(
28 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
29 new AsynchronousPolicyLoader(delegate_.release())));
30 provider_->Provide(store_.get());
31 }
32
33 TEST_F(AsynchronousPolicyTestBase, ProvideAfterRefresh) {
34 InSequence s;
35 DictionaryValue* original_policies = new DictionaryValue();
36 original_policies->SetBoolean(policy::key::kSyncDisabled, true);
37 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(original_policies));
38 DictionaryValue* refresh_policies = new DictionaryValue();
39 refresh_policies->SetBoolean(
40 policy::key::kJavascriptEnabled,
41 true);
42 EXPECT_CALL(*delegate_, Load()).WillOnce(Return(refresh_policies));
43 EXPECT_CALL(*store_, Apply(policy::kPolicyJavascriptEnabled, _)).Times(1);
44 AsynchronousPolicyLoader* loader = new AsynchronousPolicyLoader(
45 delegate_.release());
46 provider_.reset(new AsynchronousPolicyProvider(
47 ConfigurationPolicyPrefStore::GetChromePolicyDefinitionList(),
48 loader));
49 loop_.RunAllPending();
50 loader->Reload();
51 loop_.RunAllPending();
52 provider_->Provide(store_.get());
53 }
54
55 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698